/*!
    \file  systick.c
    \brief the systick configuration file
*/

/*
    Copyright (C) 2017 GigaDevice

    2017-06-06, V1.0.0, firmware for GD32F3x0
*/

#include "gd32f3x0.h"
#include "systick.h"

volatile static uint32_t delay;


void systick_config(void)
{
    // setup systick timer for 1000Hz interrupts
    if (SysTick_Config(SystemCoreClock / 10000U))
    {
        while (1)
        {
            
        }
    }
    // configure the systick handler priority
    NVIC_SetPriority(SysTick_IRQn, 0x00U);
}


void delay_1ms(uint32_t count)
{
    delay = count*10;
    while(0U != delay)
    {
    }
}
void delay_100us(uint32_t count)
{
    delay = count;
    while(0U != delay){
    }
}

void SysTick_Handler(void)
{
    if(delay)delay--;
}
